package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author: 笨蛋超人不会飞
 * Date:  18:12
 */
@Mapper
public interface DishMapper {



    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    Page<Dish> selectAllDish(DishPageQueryDTO dishPageQueryDTO);

    @Select("select * from dish where id = #{id}")
    Dish selectById(Long id);

    @Select("delete from dish where id = #{id}")
    void deleteById(Long id);
    @AutoFill(value = OperationType.UPDATE)
    void updateById(Dish dish);

    @Select("select * from dish where category_Id =#{categoryId} and status=#{status}")
    List<Dish> list(Dish dish);


    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getBySetmealId(Long id);


}
